package com.compass.doctor.ui.mine

import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import com.compass.doctor.databinding.ActivityWithdrawBinding
import com.compass.doctor.dialog.ChooseBankCardDialog
import com.compass.doctor.base.BaseVBActivity
import com.compass.doctor.ui.mine.viewmodel.IntegralViewModel
import com.compass.framework.constant.KEY_WALLET_MONEY
import com.compass.framework.ext.onClick
import com.compass.framework.model.WithdrawType
import com.compass.framework.utils.StatusBarSettingHelper

/**
 * Description： 钱包提现
 * Date:2023/12/26 20:25
 */
class WithdrawActivity : BaseVBActivity<ActivityWithdrawBinding>() {

    companion object {
        fun start(context: Context, money: Double?) {
            val intent = Intent(context, WithdrawActivity::class.java)
            intent.putExtra(KEY_WALLET_MONEY, money)
            context.startActivity(intent)
        }
    }

    private var withdrawType: MutableList<WithdrawType> = mutableListOf()
    private val integralViewModel: IntegralViewModel by viewModels()

    private var withBalance: Double = 0.0
    override fun initView(savedInstanceState: Bundle?) {
        StatusBarSettingHelper.setStatusBarTranslucent(this)
        StatusBarSettingHelper.statusBarLightMode(this@WithdrawActivity, true)
        mBinding.clyCard.onClick {
            integralViewModel.getWithdrawType()
        }
        withBalance = intent.getDoubleExtra(KEY_WALLET_MONEY, 0.0)

        mBinding.apply {
            tvCanWithdraw.text = "可提现金额为${withBalance}元"
        }

        mBinding.tvAllCost.onClick {
            withBalance.let {
                if (withBalance > 0) mBinding.edtHistoryPresentIllness.setText(withBalance.toString())
            }
        }

        mBinding.tvSubmit.onClick {

        }
    }

    override fun initData() {
        integralViewModel.walletDrawTypeLiveData.observe(this) {
            it?.let {
                withdrawType = it
                ChooseBankCardDialog.Builder(this, withdrawType).show()
            }
        }

    }
}